﻿
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../layui/css/layui.css" media="all">
<link rel="stylesheet" href="css/myCss.css">
<script src="../layui/layui.js" charset="utf-8"></script>
<script src="js/jquery-1.12.4.js" type="text/javascript"></script>
<script type="text/javascript">
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]); return null; //返回参数值
    }
    //获取图片真实宽高
    function getImageWidth(url, callback) {
        var img = new Image();
        img.src = url;

        // 如果图片被缓存，则直接返回缓存数据
        if (img.complete) {
            callback(img.width, img.height);
        } else {
            // 完全加载完毕的事件
            img.onload = function () {
                callback(img.width, img.height);
            }
        }
    }
</script>
  
    <script type="text/javascript">

        layui.use(['form', 'upload'], function () {
            var form = layui.form();
            form.render();

            $("#myaddClick").click(function () {
                $("#add").show();
                $(".addList").hide();
            });

            layui.upload({
                url: 'perform/updateImg_do.html'
                 , before: function (input) {
                     parent.layer.msg('正在上传...', {
                         icon: 16
                        , shade: 0.01
                     });
                 }
                , success: function (res) {
                    $("#mydivimg").show();
                    $("#mydivimg").attr("src", "../UploadPhotos/" + res.msg);
                    parent.layer.closeAll('loading'); //关闭等待层
                    $("#G_Img").val("/UploadPhotos/" + res.msg);
                    parent.layer.msg("上传成功!", { time: 500 });
                }
            });

            $("#mydivimg").click(function () {
                parent.layer.open({
                    type: 1 //Page层类型
                  , area: ['auto', 'auto']
                  , title: false
                  , closeBtn: 1
                  , shadeClose: true
                  , skin: 'layui-layer-nobg' //没有背景色
                  , shade: 0.6 //遮罩透明度
                  , maxmin: false //允许全屏最小化
                  , anim: 5 //0-6的动画形式，-1不开启
                  , content: '<div style="text-align:center"><img style = "max-width:1150px;" src="' + $("#G_Img").val() + '" /></div>'
                });
            });

        });

        function deleteB(myId) {//单个删除
            
              var index = parent.layer.confirm('你确定要删除吗？', {
                  btn: ['删除', '我再想想'] //按钮
              }, function () {
                  parent.layer.close(index);
                  location.href = 'G_slide.html?id=' + myId + "&action=del";

              }, function () {
                  parent.layer.close(index);
              });
        }
    </script>
</head>
<body>
    <a class='layui-btn addList'  id="myaddClick"><!--href="G_slide.html?action=tab1"--><i class="layui-icon">
        &#xe61f;</i> 添加幻灯片</a>
    <div style="display:none;" id="add">
        <blockquote class="layui-elem-quote">
            添加幻灯片</blockquote>
        <form class="layui-form" action="G_slide.html?action=add" method="post">
        <input type="hidden" id="leix" name="leix" value="" />
        <div class="layui-form-item">
            <label class="layui-form-label">
                说明</label>
            <div class="layui-input-block">
                <input type="text" name="txtG_name" value="" lay-verify="required"
                    placeholder="请输入说明文字" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                链接地址</label>
            <div class="layui-input-block">
                <input type="text" name="txtG_address" value="" 
                    class="layui-input"><!--lay-verify="url"-->
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                图片</label>
            <div class="layui-input-inline">
                <input type="hidden" name="G_Img" id="G_Img" value="images/Head.jpg" lay-verify="required" />
                <input type="file" name="file-demo" lay-type="images" class="layui-upload-file">
                
                <img id="mydivimg" class="mydivimg" src="images/Head.jpg" title="点击查看" />
                
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                链接排序</label>
            <div class="layui-input-inline">
                <input type="number" name="txtG_sorting" value="" lay-verify="number"
                    placeholder="请输入链接排序" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit>
                    立即添加</button>
                <button type="reset" class="layui-btn layui-btn-primary">
                    重置</button>
            </div>
        </div>
        </form>
    </div>
    <table lay-even class="layui-table addList" lay-skin="line" >
        <thead>
            <tr>
                <th>
                    说明文字
                </th>
                <th>
                    链接地址
                </th>
                <th>
                    排序
                </th>
                <th>
                    操作
                </th>
            </tr>
        </thead>
        <tbody>
          
            <tr>
                <td>
                    baidu
                </td>
                <td>
                   http://www.baidu.com
                </td>
                <td>
                    2
                </td>
                <td>
                    <a href="G_slide.html?id=1&action=tab1" class="layui-btn layui-btn-mini"
                        title="修改"><i class="layui-icon">&#xe642;</i></a> <a title="删除" onclick="deleteB(1)"
                            class="layui-btn layui-btn-mini layui-btn-danger"><i class="layui-icon">&#xe640;</i></a>
                </td>
            </tr>
           
        </tbody>
    </table>
</body>
</html>
